<!DOCTYPE html><html lang="en"><head>
    <meta charset="UTF-8">
    <title>生产者</title>
    <script src="jquery-1.11.0.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        var fn = {
            skip_1: function(id) {
                alert("一号书店预定成功！");
                $.post("../rabbitmqsend/SendBook1",{"id":id}, function(data) {
                }, 'json');
            },skip_2: function(id) {
                alert("二号书店预定成功！");
                $.post("../rabbitmqsend/SendBook2",{"id":id},function(data) {
                }, 'json');
            }
        }
    </script>
    <script>

        $.ajax({
            url: '../rabbitmqsend/getAllBook',
            success:function (date){
                debugger;
                var books=date.books;
                var html="<tr>编号<td></td><td>书名</td><td>价格</td><td>一号书店</td><td>二号书店</td></tr>";
                for( var i=0;i<books.length;i++){
                    html=html+"<tr><td>"+books[i].id+"</td><td>"+books[i].name+"</td><td>"+books[i].jiage+"</td><td><button><a href='/SendBook1?id="+books[i].id+"' onclick='fn.skip_1("+books[i].id+");return false'>购买</button></td><td><button><a onclick='fn.skip_2("+books[i].id+");return false'>购买</button></td></tr>"
                }
                $('#book').html(html);
            }
        })


    </script></head><body><table id="book">

</table></body></html>